﻿using de.wolfmarco.pas.Shared.Interfaces;
using de.wolfmarco.pas.Shared.MessageBoxes;
using de.wolfmarco.pas.Shared.MVVM;
using Microsoft.Practices.Prism.Commands;
using Microsoft.Practices.Prism.Modularity;
using Microsoft.Practices.Prism.Regions;
using System;
using System.Windows;

namespace de.wolfmarco.pas.Client.MVVM
{
    public class ShellViewModel : ModuleViewModel
    {
        public ShellViewModel(IRegionManager regionManager, IModuleManager moduleManager)
            : base( regionManager, moduleManager )
        {
            OptionsCommand = new DelegateCommand<Window>(OnTryShowOptions, CanShowOptions);
        }

        #region OptionsCommand

        public DelegateCommand<Window> OptionsCommand { get; private set; }

        private void OnTryShowOptions(Window owner)
        {
            try
            {
                OnShowOptions(owner);
            }
            catch (Exception ex)
            {
                PASMessageBox.ShowException(ex);
            }
        }

        protected virtual void OnShowOptions(Window owner)
        {
            OptionsWindow window = new OptionsWindow();
            window.Owner = owner;
            window.ShowDialog();
        }

        protected virtual bool CanShowOptions(Window owner)
        {
            return true;
        }

        #endregion OptionsCommand
    }
}
